package com.ruoyi.chatgpt.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.chatgpt.mapper.GptDiscountMapper;
import com.ruoyi.chatgpt.domain.GptDiscount;
import com.ruoyi.chatgpt.service.IGptDiscountService;

/**
 * 优惠折扣Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-06-29
 */
@Service
public class GptDiscountServiceImpl implements IGptDiscountService 
{
    @Autowired
    private GptDiscountMapper gptDiscountMapper;

    /**
     * 查询优惠折扣
     * 
     * @param id 优惠折扣主键
     * @return 优惠折扣
     */
    @Override
    public GptDiscount selectGptDiscountById(Long id)
    {
        return gptDiscountMapper.selectGptDiscountById(id);
    }

    /**
     * 查询优惠折扣列表
     * 
     * @param gptDiscount 优惠折扣
     * @return 优惠折扣
     */
    @Override
    public List<GptDiscount> selectGptDiscountList(GptDiscount gptDiscount)
    {
        return gptDiscountMapper.selectGptDiscountList(gptDiscount);
    }

    /**
     * 新增优惠折扣
     * 
     * @param gptDiscount 优惠折扣
     * @return 结果
     */
    @Override
    public int insertGptDiscount(GptDiscount gptDiscount)
    {
        gptDiscount.setCreateTime(DateUtils.getNowDate());
        return gptDiscountMapper.insertGptDiscount(gptDiscount);
    }

    /**
     * 修改优惠折扣
     * 
     * @param gptDiscount 优惠折扣
     * @return 结果
     */
    @Override
    public int updateGptDiscount(GptDiscount gptDiscount)
    {
        gptDiscount.setUpdateTime(DateUtils.getNowDate());
        return gptDiscountMapper.updateGptDiscount(gptDiscount);
    }

    /**
     * 批量删除优惠折扣
     * 
     * @param ids 需要删除的优惠折扣主键
     * @return 结果
     */
    @Override
    public int deleteGptDiscountByIds(Long[] ids)
    {
        return gptDiscountMapper.deleteGptDiscountByIds(ids);
    }

    /**
     * 删除优惠折扣信息
     * 
     * @param id 优惠折扣主键
     * @return 结果
     */
    @Override
    public int deleteGptDiscountById(Long id)
    {
        return gptDiscountMapper.deleteGptDiscountById(id);
    }

    @Override
    public GptDiscount queryGptDiscountByCode(String code) {
        return gptDiscountMapper.queryGptDiscountByCode(code);
    }

    @Override
    public void updateDiscountStatus(String code, Long userId, Integer status) {

        gptDiscountMapper.updateDiscountUsed(code, userId, status);
    }
}
